package graphics.screens;

import function.Mp3File;
import graphics.BootColor;
import graphics.MultiLineText;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;

import boot.Boot;


public class PopUpNameScreen extends Canvas implements CommandListener {

	private final Command playCommand = new Command("Add", Command.OK, 1);
	private final Command cancelCommand = new Command("Cancel", Command.EXIT, 1);
	private Mp3File mp3;
	
	public PopUpNameScreen(Mp3File aMp3) {
		mp3 = aMp3;
	}
	
	public void setup() {
		addCommand(playCommand);
		addCommand(cancelCommand);
		setCommandListener(this);
	}
	
	protected void paint(Graphics graphics) {
		graphics.setColor(BootColor.BLACK);
		graphics.fillRect(0, 0, 240, 250);

		graphics.setColor(BootColor.BASIC_MENU_COLOR);
		graphics.drawString("Full title:", 120, (250/2 - graphics.getFont().getHeight()*2)
				, Graphics.TOP|Graphics.HCENTER);
		
		int titleY = 250/2 - graphics.getFont().getHeight();
		MultiLineText titleText = new MultiLineText(titleY, graphics);
		titleText.setContent(mp3.getTitle());
		titleText.repaint(graphics, BootColor.WHITE);
	}

	public void commandAction(Command command, Displayable disp) {

		if (command == playCommand) {
			Boot.getInstance().enqueueMp3(mp3);
			// TEST What happens for Pop-ups
		} else if (command == cancelCommand) {
			Boot.getInstance().backToSearchChoice();
		}
	}

}
